package util;

import org.springframework.util.DigestUtils;

/**
 * 关于密码的工具类
 */
public class PasswordUtil {

    /**
     * 进行md5加密
     * @param password
     * @param salt
     * @return
     */
    public static String toMd5(String password,String salt){
        String resultStr=password+salt;
        for (int i = 0; i < 5; i++) {
            resultStr=DigestUtils.md5DigestAsHex(resultStr.getBytes());
        }
        return resultStr;
    }

    /**
     * 进行md5加密
     * @param password
     * @param salt
     * @param number
     * @return
     */
    public static String toMd5(String password,String salt,Integer number){
        String resultStr=password+salt;
        for (int i = 0; i < number; i++) {
            resultStr=DigestUtils.md5DigestAsHex(resultStr.getBytes());
        }
        return resultStr;
    }

}
